<html>
	<head

	</head>
	<body>

	<style>
		#customers {
			font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
			width: 100%;
			border-collapse: collapse;
		}
		#customers td, #customers th {
			font-size: 1em;
			border: 1px solid #98bf21;
			padding: 3px 7px 2px 7px;
		}
		#customers th {
			font-size: 1.1em;
			text-align: left;
			padding-top: 5px;
			padding-bottom: 4px;
			background-color: #A7C942;
			color: #ffffff;
		}
		#customers tr.alt td {
			color: #000000;
			background-color: #EAF2D3;
		}
	</style>
	<?php
	$trackID = $_REQUEST['trackID'];
	$trackID = intval($trackID);
	$jsonObject = file_get_contents("http://obdproject.hostoi.com/requestTrack.php?trackID=" . $trackID);

	//hack: remove stupid stuff that is added by our free hoster
	$jsonObject = explode("<", $jsonObject);
	$jsonObject = $jsonObject[0];

	$jsonObject = json_decode($jsonObject);

	echo "<h1>Track " . $jsonObject -> id . " from " . $jsonObject -> user -> userName . " on " . $jsonObject -> date . "</h1>";
	echo "<h2>" . "Car: " . $jsonObject -> car -> carName . "</h2>";
	echo "<a> Horsepower: " . $jsonObject -> car -> carHorsePower . "</a>";

	echo "
		<table id=\"customers\">\n";
		?>
		<tr><th>Position</th><th>Consumption</th><th>Speed</th><th>Engine Load</th><th>Engine Coolant Temp.</th>
		<th>Runtime</th><th>Air Temperature</th><th>Oil Temperature</th><th>fuelRate</th><th>CMV</th><th>Time</th></tr>
		<?php
		$alt = false;
		foreach ($jsonObject->
		tracks as $track) {
			if ($alt == true) {
				echo "<tr class=\"alt\">\n";
				$alt = false;
			} else {
				echo "<tr>\n";
				$alt = true;
			}
			//			echo "<td>" . $track -> lat . "</td>";
			//			echo "<td>" . $track -> lon . "</td>";
			//			echo "<td>" . $track -> alt . "</td>";
			echo "<td><a href=\"http://maps.google.com/maps?q=" . $track -> lat . "," . $track -> lon . 
			"+(Position of " . $jsonObject -> user -> userName . " on " . $jsonObject -> date . ")\" target=\"blank\">Position</a></td>";
			echo "<td>" . $track -> consumption . "</td>";
			echo "<td>" . $track -> speed . "</td>";
			echo "<td>" . $track -> engineLoad . "</td>";
			echo "<td>" . $track -> engineCoolantTemperature . "</td>";
			echo "<td>" . $track -> engineRuntime . "</td>";
			echo "<td>" . $track -> airTemperature . "</td>";
			echo "<td>" . $track -> oilTemperature . "</td>";
			echo "<td>" . $track -> fuelRate . "</td>";
			echo "<td>" . $track -> cmv . "</td>";
			echo "<td>" . $track -> time . "</td>";
			echo "
</tr>\n";

		}

		echo "
</table>\n";
		?>

		</body>
</html>